package cn.client.ui.view.main.user

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import cn.client.ui.components.content1
import cn.client.ui.components.content2


@Composable
fun TabContentInUser(
    selectedTabIndex: MutableState<Int>
) {

    TabRow(
        selectedTabIndex = selectedTabIndex.value,
        modifier = Modifier.fillMaxWidth()
    ) {
        /* tab1 */
        Tab(
            selected = selectedTabIndex.value == 0,
            onClick = { selectedTabIndex.value = 0 },
            text = { Text(text = "tab1") }
        )
        /* tab2 */
        Tab(
            selected = selectedTabIndex.value == 1,
            onClick = { selectedTabIndex.value = 1 },
            text = { Text(text = "tab2") }
        )
    }
    NowContent(index = selectedTabIndex.value)
}


@Composable
fun NowContent(index: Int) {
    when (index) {
        0 -> {
            // Tab 1 的内容
            content1()
        }
        1 -> {
            // Tab 2 的内容
            content2()
        }
    }
}
